import Cookies from 'js-cookie'

const TokenKey = 'Authorization'
const userTokenKey = 'userToken'
const userInfo = 'userInfo'
const permissions = 'permissions';
// const 

// token
export function getToken(name) {
  if(name === undefined){
    name = TokenKey
  }
  return Cookies.get(name)
}
export function setToken(token) {
  return Cookies.set(TokenKey, token)
}
export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function setWebApiToken(user,token) {
  return Cookies.set(user, token)
}

//usertoken
export function getUserToken(name) {
  if(name === undefined){
    name = userTokenKey
  }
  return Cookies.get(name)
}
export function setUserToken(token) {
  return Cookies.set(userTokenKey, token)
}
export function removeUserToken() {
  return Cookies.remove(userTokenKey)
}

export function getUserInfo(name) {
  if(name === undefined){
    name = userInfo
  }
  return Cookies.get(name)
}
export function setUserInfo(user) {
  return Cookies.set(userInfo, user)
}
export function removeUserInfo() {
  return Cookies.remove(userInfo)
}

export function getPermissions(name) {
  if(name === undefined){
    name = permissions
  }
  return Cookies.get(name)
}
export function setPermissions(p) {
  return Cookies.set(permissions, p)
}
export function removePermissions() {
  return Cookies.remove(permissions)
}